<?php
require_once  __DIR__ . '/includes/authenticate.php';
include_once __DIR__ . '/db_bb_connect.php';

$username = $_SESSION['username'];

$sql2 = "SELECT user_key FROM users WHERE username = '$username'";

  if ($db->query($sql2)) {  

    $result = $db->query($sql2);
    $row = $result->fetch_assoc();
    $playerID = $row['user_key'];
?>

<script type="text/javascript">
  
function loadPlayerHome( e ) {
  $.ajax({
    type: "POST",
    url: "./home_player.php",
    data: { playerID: "<?= $playerID; ?>"},
    success: function(data) {
      $("#content").html(data);
    },
    error: function (xhr, status, error) {
          alert(xhr.responseText);
        }
  }); 
  e.preventDefault();
};

loadPlayerHome();

</script>

<?php
    } else {
      echo "Error: " . $sql . "<br>" . $db->error;
    }


?>

